package com.dpi.cgdc.data.controller;

import com.dpi.cgdc.data.kafka.KafkaProducer;
import com.dpi.cgdc.data.model.vo.KafkaVO;
import com.dpi.cgdc.data.model.vo.ResultVo;
import com.dpi.cgdc.data.service.RawDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Zhangbochao
 * @Date: 10:22 2025/2/6
 * @Description:
 * @modifiedBy:
 * @Version: 1.0
 */
@Api(tags = "原始数据管理接口")
@RestController
@RequestMapping("/raw/v1")
@RequiredArgsConstructor
@Slf4j
public class RawDataController {

    @Autowired
    private RawDataService rawDataService;

    @Autowired
    private KafkaProducer kafkaProducer;

    /**
     * kafka
     *
     * @param kafkaVO kafka topic message
     * @return
     */
    @PostMapping("kafka")
    @ApiOperation("kafka")
    public ResultVo kafka(@RequestBody KafkaVO kafkaVO) {
        kafkaProducer.sendMessage(kafkaVO.getTopic(), kafkaVO.getMessage());
        return ResultVo.successDefault();
    }

}
